import axios from "axios"
// 是否为生产环境
//const isProd = process.env.NODE_ENV === 'production'
// 根据环境判断baseURL
//const apiUrl = isProd ? 'http://hbdm.ehaier.com/' : '/api'
const apiUrl = 'https://hbdm.ehaier.com/'
const isMock = false

//获取首页数据
export function queryHomeData() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/data.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberData`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}

//
/*export function queryPercentData() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/percent.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberData`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}*/

/*export function querySalesData() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/sales.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberData`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}*/
//左上
export function queryLeftTop() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/leftTop.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}autodigitalEvaluation/findLeftTop`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}
//左中
/*export function queryLeftMid() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/leftMid.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberData`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}*/
//左下方
/*export function queryLeftBottom() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/leftBottom.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberData`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}*/



//下方
export function queryBottom() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/bottom.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}autodigitalEvaluation/findMiddleBottom`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}

//右上
/*
export function queryRightTop() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/rightTop.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberData`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}
*/

//右中
/*export function queryRightMid() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/rightMid.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}digitalEvaluation/hbdmNumberData`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}*/
//右下
export function queryRightBottom() {
    return new Promise((resolve, reject) => {
        if (isMock) {
            axios.get('./data/home/rightBottom.json').then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        } else {
            axios.post(`${apiUrl}autodigitalEvaluation/findRightBottom`).then(res => {
                resolve(res)
            }).catch(err => {
                reject(err)
            })
        }
    })
}
